package com.efuture.collection;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @ClassNAME PropertiesTest
 * @Description Properties基本使用
 * @Author zhaoshanshan
 * @Date 2021/9/7 5:06 下午
 * @Version 1.0
 */
public class PropertiesTest {

    public static void main(String[] args) {
        //创建对象
        Properties properties = new Properties();
        //添加数据
        properties.put(1,"zhangshan");
        properties.put(2,"lisi");
        properties.put(3,"wangwu");
        properties.put(4,"zhaoliu");
        //取出数据
        System.out.println( properties.get(1));
        System.out.println( properties.get(2));
        System.out.println( properties.get(3));
        System.out.println( properties.get(4));
        System.out.println("======================");
        //遍历
        Set<Map.Entry<Object,Object>> propertiesSet =  properties.entrySet();
        Iterator it = propertiesSet.iterator();
        while (it.hasNext()){
            Object obj = it.next();
            System.out.println(obj);
        }
        System.out.println("======================");
        Set<Object> keySet = properties.keySet();
        Iterator iterator = keySet.iterator();
        while (iterator.hasNext()){
            Object key = iterator.next();
            System.out.println(key+"="+properties.get(key));
        }

    }
}